// 全局指令

const directives = [
  "permission"
  // 'wave',
  // 'loading'
];

export default Vue => {
  directives.forEach(i => {
    // eslint-disable-next-line import/no-dynamic-require
    Vue.use(require(`./modules/${i}.js`).default);
  });

  Vue.directive("focus", {
    inserted(el) {
      el.focus();
    }
  });

  // 防重复点击(指令实现)
  Vue.directive("preventReClick", {
    inserted(el, binding) {
      el.addEventListener("click", () => {
        if (!el.disabled) {
          el.disabled = true;
          setTimeout(() => {
            el.disabled = false;
          }, binding.value || 1000);
        }
      });
    }
  });
};
